# 1.导库
from pyecharts import options as opts
# 画什么图导入什么类
from pyecharts.charts import Line
#
from pyecharts.globals import ThemeType
# 2.初始化配置
my_init_opts = opts.InitOpts(width='800px',height='500px',page_title='折线图',theme=ThemeType.PURPLE_PASSION)#画布大小，主题
line = Line(my_init_opts)

# 添加数据，x/y
x = ['周一','周二','周三','周四','周五','周六','周日']
y1 = [820,932,901,934,1290,1330,1320]
y2 = [550,432,601,632,790,830,820]
line.add_xaxis(xaxis_data=x)
line.add_yaxis(series_name='店铺1',y_axis=y1)
line.add_yaxis(series_name='店铺2',y_axis=y2,symbol='diamond',symbol_size=8,label_opts=opts.LabelOpts(color='green'),
               linestyle_opts=opts.LineStyleOpts(color='red',width=5)
               )

# 4.全局配置:set_global_opts
line.set_global_opts(
    # 标题
    title_opts=opts.TitleOpts(title='两个店铺一周内的销售额',pos_left='center'),
    # 坐标轴标题
    xaxis_opts=opts.AxisOpts(name='日期',name_gap=35,name_location='center'),
    yaxis_opts=opts.AxisOpts(name='销售额/万元',name_gap=35,name_location='center'),
    # 图例进行配置
    legend_opts=opts.LegendOpts(pos_right='12%',pos_top='75%'),
    # 提示框
    tooltip_opts=opts.TooltipOpts(is_show=True,trigger='axis',trigger_on='mousemove|click',axis_pointer_type='cross'),
    # 工具箱：toolbox
    toolbox_opts=opts.ToolboxOpts(is_show=True,pos_right='center')
)

# 5.渲染图
line.render('line.html')